package com.simplegui.examples.pong;

import static com.simplegui.examples.pong.PongConfigurations.*;

import java.awt.Color;
import java.awt.Point;

import com.simplegui.api.Canvas;
import com.simplegui.api.handlers.DrawHandler;

public class PongDrawHandler implements DrawHandler{
	
	private Pong pong;
	
	public PongDrawHandler(Pong pong) {
		super();
		this.pong = pong;
	}

	@Override
	public void draw(Canvas c) {
		pong.executeLogic();

		// draw mid line and gutters
		int paddlesWidth = pong.getLeftPaddle().getWidth();
		c.drawLine(new Point(FRAME_WIDTH / 2, 0), new Point(FRAME_WIDTH / 2, FRAME_HEIGHT), 1, Color.WHITE);
		c.drawLine(new Point(paddlesWidth, 0), new Point(paddlesWidth, FRAME_HEIGHT), 1, Color.WHITE);
		c.drawLine(new Point(FRAME_WIDTH - paddlesWidth, 0) , new Point(FRAME_WIDTH - paddlesWidth, FRAME_HEIGHT), 1, Color.WHITE);
		
		// draw left paddle
		pong.getLeftPaddle().draw(c);
		
		// draw right paddle
		pong.getRightPaddle().draw(c);
		
		// draw ball
		pong.getBall().draw(c);

		// draw scores
		pong.getScore().draw(c);
	}

}
